# Contributor: Maxim Karasev <mxkrsv@disroot.org>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=py3-sympy
pkgver=1.13.3
pkgrel=0
pkgdesc="Computer algebra system written in pure Python"
url="https://www.sympy.org/"
arch="noarch"
license="BSD-3-Clause"
depends="py3-mpmath"
makedepends="
	py3-gpep517
	py3-setuptools
	py3-wheel
	"
checkdepends="
	py3-hypothesis
	py3-pytest-rerunfailures
	py3-pytest-timeout
	py3-pytest-xdist
	"
subpackages="$pkgname-doc $pkgname-pyc"
source="https://github.com/sympy/sympy/archive/sympy-$pkgver/py3-sympy-$pkgver.tar.gz"
builddir="$srcdir/sympy-sympy-$pkgver"
# DO NOT MERGE with tests enabled: they are fine in CI,
# but get stuck and never complete on the builders.
options="!check"

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	local allow_fail='no'
	case "$CARCH" in
		riscv64) allow_fail='yes' ;;
	esac

	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl

	timeout 2h .testenv/bin/python3 -m pytest \
		-n auto \
		--maxprocesses 24 \
		--timeout 600 \
		--reruns 3 \
	|| [ "$allow_fail" = yes ]
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl

	find "$pkgdir" -type d -name "tests" -exec rm -r {} +
}

sha512sums="
0b8b222c10c8a93b93a97486c86e898dbe35a6d33b8142aa8c6645cfe0da8b74551664d52992d9de9144365856ee49587ec414ef13f0658f36712cbf153be7e2  py3-sympy-1.13.3.tar.gz
"
